<template>
  <div class="rightChart">
    <div class="top">
      <div class="title1">扫频模式参数配置</div>
    </div>

    <div class="title">频率</div>
    <div class="item">
      <div class="content">
        <div class="label">中心频率：</div>
        <div class="value">
          <el-input
            v-model.trim="scanForm.center"
            placeholder=""
            size="mini"
            clearable
            @blur="checkCenter"
          ></el-input>
        </div>
        <span style="width: 80px"
          ><el-select
            v-model="scanUnit.center"
            @change="checkCenter"
            size="mini"
          >
            <el-option label="MHz" value="MHz"></el-option>
            <el-option label="GHz" value="GHz"></el-option>
          </el-select>
        </span>
      </div>
      <div class="content">
        <div class="label">扫频宽度：</div>
        <div class="value">
          <el-input
            v-model="scanForm.span"
            placeholder=""
            size="mini"
            clearable
            @blur="checkSpan"
          ></el-input>
        </div>
        <span style="width: 80px">
          <el-select v-model="scanUnit.span" @change="checkSpan" size="mini">
            <el-option label="KHz" value="KHz"></el-option>
            <el-option label="MHz" value="MHz"></el-option>
            <el-option label="GHz" value="GHz"></el-option>
          </el-select>
        </span>
      </div>
      <div class="content" v-if="false">
        <div class="label">起始频率：</div>
        <div class="value">
          <el-input-number
            style="width: 100%"
            v-model="scanForm.startFre"
            size="mini"
            :min="deviceType === 'TOEC01' ? 950 : 0.009"
            :max="deviceType === 'TOEC01' ? 2150 : 6000"
            :controls="false"
            @blur="changeCenterFre"
            clearable
          >
          </el-input-number>
        </div>
        <span style="width: 80px">
          <el-select v-model="scanUnit.startFre" size="mini">
            <el-option label="MHz" value="MHz"></el-option>
          </el-select>
        </span>
      </div>
      <div class="content" v-if="false">
        <div class="label">终止频率：</div>
        <div class="value">
          <el-input-number
            style="width: 100%"
            v-model="scanForm.stopFre"
            size="mini"
            :min="deviceType === 'TOEC01' ? 950 : 0.009"
            :max="deviceType === 'TOEC01' ? 2150 : 6000"
            :controls="false"
            @blur="changeCenterFre"
            clearable
          >
          </el-input-number>
        </div>
        <span style="width: 80px">
          <el-select v-model="scanUnit.stopFre" size="mini">
            <el-option label="MHz" value="MHz"></el-option> </el-select
        ></span>
      </div>
      <div class="content">
        <div class="label">步进：</div>
        <div class="value">
          <el-select size="mini" v-model="scanForm.step" style="width: 100%">
            <el-option label="5MHz" :value="4"></el-option>
            <el-option label="10MHz" :value="3"></el-option>
            <el-option label="20MHz" :value="2"></el-option>
            <el-option label="40MHz" :value="1"></el-option>
          </el-select>
        </div>
        <span style="width: 80px">&emsp;</span>
      </div>
    </div>
    <div class="title">幅度</div>
    <div class="item">
      <div class="content">
        <div class="label">增益：</div>
        <div class="value">
          <el-input-number
            v-model="scanForm.zengyi"
            size="mini"
            :min="0"
            :max="30"
            :controls="false"
            style="width: 100%"
          >
          </el-input-number>
        </div>
        <span style="width: 80px">
          <el-select value="db" size="mini">
            <el-option label="db" value="db"></el-option>
          </el-select>
        </span>
      </div>
    </div>
    <div class="title">分辨率</div>
    <div class="item">
      <div class="content">
        <div class="label">分辨率：</div>
        <div class="value">
          <el-input
            v-model="scanForm.rbw"
            placeholder=""
            size="mini"
            clearable
            @blur="checkRbw"
          ></el-input>
        </div>
        <span style="width: 80px">
          <el-select v-model="scanUnit.rbw" @change="checkRbw" size="mini">
            <el-option label="Hz" value="Hz"></el-option>
            <el-option label="KHz" value="KHz"></el-option>
          </el-select>
        </span>
      </div>
      <div class="content">
        <div class="label">自动分辨率：</div>
        <div class="value" style="text-align: left">
          <el-checkbox v-model="scanForm.autoRbw" @change="changeRbw"
            >使用自动分辨率</el-checkbox
          >
        </div>
        <span style="width: 80px"> &emsp; </span>
      </div>
      <div class="content">
        <div class="label">视频带宽：</div>
        <div class="value">
          <el-input-number
            v-model="vbw"
            size="mini"
            style="width: 100%"
            :min="0.01"
            :max="
              scanUnit.rbw === 'Hz' ? scanForm.rbw * 1 : scanForm.rbw * 1000
            "
            :controls="false"
          >
          </el-input-number>
        </div>
        <span style="width: 80px">
          <el-select size="mini" value="Hz">
            <el-option label="Hz" value="Hz"></el-option>
          </el-select>
        </span>
      </div>
      <div class="content">
        <div class="label">自动视频带宽：</div>
        <div class="value" style="text-align: left">
          <el-checkbox v-model="autoVbw" @change="changeAutoVbw">
            使用自动视频带宽
          </el-checkbox>
        </div>
        <span style="width: 80px"> &emsp; </span>
      </div>
    </div>
    <div class="title">采集</div>
    <div class="item">
      <div class="content">
        <div class="label">平滑次数：</div>
        <div class="value">
          <el-select size="mini" v-model="scanForm.smooth" style="width: 100%">
            <el-option label="1" :value="1"></el-option>
            <el-option label="2" :value="2"></el-option>
            <el-option label="4" :value="4"></el-option>
            <el-option label="8" :value="8"></el-option>
            <el-option label="16" :value="16"></el-option>
          </el-select>
        </div>
        <span style="width: 80px">&emsp;</span>
      </div>
      <div class="content" v-show="false">
        <div class="label">类型：</div>
        <div class="value">
          <el-select
            v-model="scanForm.detectType"
            style="width: 100%"
            placeholder=""
            @change="changeDetectType"
            :multiple="true"
            :multiple-limit="3"
          >
            <el-option
              v-for="item in typeOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
        <!-- <span style="width: 80px">&emsp;</span> -->
      </div>
      <div class="content" v-show="false">
        <div class="label">扫描时间：</div>
        <div class="value">
          <el-input
            v-model="scanForm.sweepTime"
            placeholder=""
            size="mini"
            clearable
          ></el-input>
        </div>
        <span style="width: 80px"
          ><el-select value="ms" size="mini">
            <el-option label="ms" value="ms"></el-option> </el-select
        ></span>
      </div>
      <div class="content">
        <div class="label">重置FFT：</div>
        <div class="value" style="text-align: left">
          <el-button size="mini" @click="resetFFT" style="width: 100px"
            >刷新</el-button
          >
        </div>
        <span style="width: 80px"></span>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "ScanSetting",
  data() {
    return {
      scanForm: {
        center: "", // 中心频点
        span: "", // 扫频宽度
        startFre: "", // 起始频率
        stopFre: "", // 终止频率
        step: "", // 步进
        zengyi: "", // 增益设置
        rbw: "", // 分辨率
        smooth: "", // 平滑次数
        sweepTime: "", // 扫描时间
        detectType: [], // 采集类型
        autoRbw: true,
      },
      scanUnit: {
        center: "MHz", // 中心频点单位
        span: "MHz", // 扫频宽度单位
        startFre: "MHz", // 起始频率单位
        stopFre: "MHz", // 终止频率单位
        rbw: "Hz", // 分辨率率单位
      },
      typeOptions: [
        /* {
          label: '实时更新',
          value: 1
        }, */
        {
          label: "FFT平均",
          value: "2",
        },
        {
          label: "FFT最大",
          value: "3",
        },
        {
          label: "FFT最小",
          value: "4",
        },
        /* {
          label: 'FFT最大和最小',
          value: 5
        } */
      ],
      shepinOptions: [
        {
          label: "L波段",
          value: 1,
        },
        {
          label: "70MHz",
          value: 2,
        },
        {
          label: "140MHz",
          value: 3,
        },
      ],

      maxYVal: -80, // 参考电平 => Y轴最大值
      minYVal: -110, // 最小电平 => Y轴最小值

      vbw: undefined, // 视频带宽：单独配置
      autoVbw: true,

      deviceType: "", // 设备类型
    };
  },
  props: ["url"],
  inject: ["userMark", "detectType1"],
  methods: {
    getValue(val, type1, type2) {
      if (!val) return null;
      if (type1 === type2) {
        return val;
      } else {
        if (type1 === "KHz") {
          if (type2 === "MHz") {
            return val / 1000;
          } else {
            return val / 1000000;
          }
        } else if (type1 === "MHz") {
          if (type2 === "KHz") {
            return val * 1000;
          } else {
            return val / 1000;
          }
        } else {
          if (type2 === "KHz") {
            return val * 1000000;
          } else {
            return val * 1000;
          }
        }
      }
    },
    // 校验中心频点范围
    checkCenter() {
      if (this.scanForm.center == "") return;
      if (this.deviceType === "TOEC01") {
        if (this.scanUnit.center === "MHz") {
          if (isNaN(this.scanForm.center)) {
            this.scanForm.center = 950; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.center = Math.max(
              950,
              Math.min(2150, Number(this.scanForm.center))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          if (isNaN(this.scanForm.center)) {
            this.scanForm.center = 0.95; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.center = Math.max(
              0.95,
              Math.min(2.15, Number(this.scanForm.center))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
        const span = this.getValue(
          this.scanForm.span,
          this.scanUnit.span,
          "MHz"
        );
        const center = this.getValue(
          this.scanForm.center,
          this.scanUnit.center,
          "MHz"
        );
        if (center - span / 2 < 950) {
          this.scanUnit.span = "MHz";
          this.scanForm.span = (center - 950) * 2;
        } else if (center + span / 2 > 2150) {
          this.scanUnit.span = "MHz";
          this.scanForm.span = (2150 - center) * 2;
        }
      } else {
        // BB60C设备
        if (this.scanUnit.center === "MHz") {
          if (isNaN(this.scanForm.center)) {
            this.scanForm.center = 0.1; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.center = Math.max(
              0.1,
              Math.min(6000, Number(this.scanForm.center))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          if (isNaN(this.scanForm.center)) {
            this.scanForm.center = 0.0001; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.center = Math.max(
              0.0001,
              Math.min(6, Number(this.scanForm.center))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
      }

      if (this.scanForm.center != "" && this.scanForm.span != "") {
        this.changeFre();
      }
    },
    // 校验扫频宽度范围
    checkSpan() {
      if (this.scanForm.span == "") return;
      if (this.deviceType === "BB60C") {
        const max =
          this.scanForm.center - 0.009 + (6000 - this.scanForm.center);
        const map = { 1: 40, 2: 20, 3: 10, 4: 5 };
        const min = map[this.scanForm.step];
        if (this.scanUnit.span === "KHz") {
          // KHz
          if (isNaN(this.scanForm.span)) {
            this.scanForm.span = min * 1000; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.span = Math.max(
              min * 1000,
              Math.min(max * 1000, Number(this.scanForm.span))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else if (this.scanUnit.span === "MHz") {
          // MHz
          if (isNaN(this.scanForm.span)) {
            this.scanForm.span = min; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.span = Math.max(
              min,
              Math.min(max, Number(this.scanForm.span))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          // GHz
          if (isNaN(this.scanForm.span)) {
            this.scanForm.span = min / 1000; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.span = Math.max(
              min / 1000,
              Math.min(max / 1000, Number(this.scanForm.span))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
      } else {
        if (this.scanUnit.span === "KHz") {
          // KHz
          if (isNaN(this.scanForm.span)) {
            this.scanForm.span = 100; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.span = Math.max(
              100,
              Math.min(1200000, Number(this.scanForm.span))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else if (this.scanUnit.span === "MHz") {
          // MHz
          if (isNaN(this.scanForm.span)) {
            this.scanForm.span = 0.1; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.span = Math.max(
              0.1,
              Math.min(1200, Number(this.scanForm.span))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          // GHz
          if (isNaN(this.scanForm.span)) {
            this.scanForm.span = 0.0001; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.span = Math.max(
              0.0001,
              Math.min(1.2, Number(this.scanForm.span))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
        const span = this.getValue(
          this.scanForm.span,
          this.scanUnit.span,
          "MHz"
        );
        const center = this.getValue(
          this.scanForm.center,
          this.scanUnit.center,
          "MHz"
        );
        if (center - span / 2 < 950) {
          this.scanUnit.center = "MHz";
          this.scanForm.center = 950 + span / 2;
        } else if (center + span / 2 > 2150) {
          this.scanUnit.center = "MHz";
          this.scanForm.center = 2150 - span / 2;
        }
      }

      if (this.scanForm.center != "" && this.scanForm.span != "") {
        this.changeFre();
      }
      this.changeRbwVBW();
    },
    // 校验分辨率范围
    checkRbw() {
      if (this.scanForm.rbw == "") return;
      const val = this.getValue(this.scanForm.span, this.scanUnit.span, "MHz");

      if (val <= 10) {
        if (this.scanUnit.rbw === "KHz") {
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 0.01; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              0.01,
              Math.min(10000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          // Hz
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 10; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              10,
              Math.min(10000000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
      } else if (val <= 30) {
        if (this.scanUnit.rbw === "KHz") {
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 0.03; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              0.03,
              Math.min(10000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          // Hz
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 30; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              30,
              Math.min(10000000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
      } else if (val <= 100) {
        if (this.scanUnit.rbw === "KHz") {
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 0.1; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              0.1,
              Math.min(10000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          // Hz
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 100; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              100,
              Math.min(10000000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
      } else if (val <= 300) {
        if (this.scanUnit.rbw === "KHz") {
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 0.4; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              0.4,
              Math.min(10000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          // Hz
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 400; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              400,
              Math.min(10000000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
      } else if (val <= 1000) {
        if (this.scanUnit.rbw === "KHz") {
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 1; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              1,
              Math.min(10000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          // Hz
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 1000; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              1000,
              Math.min(10000000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
      } else if (val <= 6000) {
        if (this.scanUnit.rbw === "KHz") {
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 3; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              3,
              Math.min(10000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        } else {
          // Hz
          if (isNaN(this.scanForm.rbw)) {
            this.scanForm.rbw = 3000; // 输入的值非数字时，重置为最小值
          } else {
            this.scanForm.rbw = Math.max(
              3000,
              Math.min(10000000, Number(this.scanForm.rbw))
            ); // 在范围内时保持原值，否则取最小值或最大值
          }
        }
      } else return;
    },
    // 带宽改变后，修改分辨率、和视频带宽
    async changeRbwVBW(flag) {
      const val = this.getValue(this.scanForm.span, this.scanUnit.span, "MHz");
      this.scanUnit.rbw = "Hz";

      if (val <= 0.49) {
        this.scanForm.rbw = 50;
        this.vbw = 1;
      } else if (val <= 1.1) {
        this.scanForm.rbw = 80;
        this.vbw = 2;
      } else if (val <= 1.9) {
        this.scanForm.rbw = 100;
        this.vbw = 3;
      } else if (val <= 3) {
        this.scanForm.rbw = 150;
        this.vbw = 5;
      } else if (val <= 6) {
        this.scanForm.rbw = 300;
        this.vbw = 10;
      } else if (val <= 9) {
        this.scanForm.rbw = 500;
        this.vbw = 15;
      } else if (val <= 20) {
        this.scanForm.rbw = 500;
        this.vbw = 20;
      } else if (val <= 39) {
        this.scanForm.rbw = 700;
        this.vbw = 25;
      } else if (val <= 210) {
        this.scanForm.rbw = 1000;
        this.vbw = 50;
      } else if (val <= 530) {
        this.scanForm.rbw = 2000;
        this.vbw = 100;
      } else if (val <= 1300) {
        this.scanForm.rbw = 3000;
        this.vbw = 150;
      }
      if (flag === true) {
        await this.sweepConfig(this.url);
        await this.changeVbw(this.url);
      }
    },
    // 使用自动分辨率
    changeRbw(newVal) {
      if (newVal) {
        const val = this.getValue(
          this.scanForm.span,
          this.scanUnit.span,
          "MHz"
        );
        this.scanUnit.rbw = "Hz";

        if (val <= 0.49) {
          this.scanForm.rbw = 50;
        } else if (val <= 1.1) {
          this.scanForm.rbw = 80;
        } else if (val <= 1.9) {
          this.scanForm.rbw = 100;
        } else if (val <= 3) {
          this.scanForm.rbw = 150;
        } else if (val <= 6) {
          this.scanForm.rbw = 300;
        } else if (val <= 9) {
          this.scanForm.rbw = 500;
        } else if (val <= 20) {
          this.scanForm.rbw = 500;
        } else if (val <= 39) {
          this.scanForm.rbw = 700;
        } else if (val <= 210) {
          this.scanForm.rbw = 1000;
        } else if (val <= 530) {
          this.scanForm.rbw = 2000;
        } else if (val <= 1300) {
          this.scanForm.rbw = 3000;
        }
      }
    },
    // 修改起止频率
    changeFre() {
      this.scanForm.startFre =
        this.getValue(this.scanForm.center, this.scanUnit.center, "MHz") -
        this.getValue(this.scanForm.span, this.scanUnit.span, "MHz") / 2;
      this.scanForm.stopFre =
        this.getValue(this.scanForm.center, this.scanUnit.center, "MHz") +
        this.getValue(this.scanForm.span, this.scanUnit.span, "MHz") / 2;
    },
    // 修改了起始、终止频率 => 修改中心频率、修改扫频宽度
    changeCenterFre(flag) {
      this.scanForm.span = this.scanForm.stopFre - this.scanForm.startFre;
      this.scanForm.center = this.scanForm.stopFre - this.scanForm.span / 2;
      this.scanUnit.span = "MHz";
      this.scanUnit.center = "MHz";
      this.changeRbwVBW(flag);
    },
    // 配置扫频参数
    async sweepConfig(url) {
      try {
        await this.sweepConfigAPI(
          {
            center: this.getValue(
              this.scanForm.center,
              this.scanUnit.center,
              "KHz"
            ),
            span: this.getValue(this.scanForm.span, this.scanUnit.span, "KHz"),
            rbw:
              this.scanUnit.rbw === "Hz"
                ? this.scanForm.rbw
                : this.scanForm.rbw * 1000,
            smooth: this.scanForm.smooth,
            zengyi: this.scanForm.zengyi * 1,
            // sweepTime: this.scanForm.sweepTime * 1,
            step: this.scanForm.step * 1,
            detectType: this.detectType1.join(","),
            // userName: "1_" + this.userMark,
            userName: "1_123456789",
          },
          url
        );
      } catch (error) {
        // console.log(error);
        throw new Error(error);
      }
    },

    // 扫频参数配置接口
    sweepConfigAPI(data, url) {
      return axios({
        url: "http://" + url + "/interface/sweep/config",
        method: "post",
        data,
      });
    },
    // 类型变化了
    changeDetectType(newList) {
      // console.log('新类型', newList)
      if (!newList.includes("2")) {
        this.$emit("showLine", "line", false);
      } else {
        this.$emit("showLine", "line", true);
      }
      if (!newList.includes("3")) {
        this.$emit("showLine", "line2", false);
      } else {
        this.$emit("showLine", "line2", true);
      }
      if (!newList.includes("4")) {
        this.$emit("showLine", "line3", false);
      } else {
        this.$emit("showLine", "line3", true);
      }
    },
    // 修改视频带宽 => 参数下发
    async changeVbw(url) {
      // 调用接口参数下发
      try {
        await this.changevbwAPI({ vbw: this.vbw }, url);
        // this.$emit('changeFitFlag')
      } catch (error) {
        console.log(error);
        this.$message.error("操作失败！");
      }
    },
    changevbwAPI(data, url) {
      return axios({
        url: "http://" + url + "/interface/vbw",
        method: "post",
        data,
      });
    },
    changeAutoVbw(val) {
      if (val) {
        const val = this.getValue(
          this.scanForm.span,
          this.scanUnit.span,
          "MHz"
        );
        this.scanUnit.rbw = "Hz";

        if (val <= 0.49) {
          this.vbw = 1;
        } else if (val <= 1.1) {
          this.vbw = 2;
        } else if (val <= 1.9) {
          this.vbw = 3;
        } else if (val <= 3) {
          this.vbw = 5;
        } else if (val <= 6) {
          this.vbw = 10;
        } else if (val <= 9) {
          this.vbw = 15;
        } else if (val <= 20) {
          this.vbw = 20;
        } else if (val <= 39) {
          this.vbw = 25;
        } else if (val <= 210) {
          this.vbw = 50;
        } else if (val <= 530) {
          this.vbw = 100;
        } else if (val <= 1300) {
          this.vbw = 150;
        }
      }
    },
    async resetFFT() {
      try {
        await this.resetFFTAPI(this.url);
        this.$message.success("刷新成功！");
      } catch (error) {
        console.log(error);
        this.$message.error("操作失败！");
      }
    },
    resetFFTAPI(url) {
      return axios({
        url: "http://" + url + "/interface/fft/reset",
        method: "post",
        data,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.rightChart {
  flex: 1;
  border: 1px solid #3c3c3c;
  margin: 10px 5px;
  display: flex;
  flex-direction: column;
  background-color: #d9dfeb;
  box-sizing: border-box;

  .top {
    display: flex;
    margin-bottom: 5px;
    height: 28px;
    line-height: 28px;

    .title1 {
      padding-left: 5px;
      font-size: 16px;
      font-weight: bold;
      color: #3c3c3c;
    }
  }
  .title {
    height: 22px;
    line-height: 22px;
    font-size: 14px;
    color: #fff;
    background-color: #4d6081;

    text-align-last: left;
    padding-left: 20px;
  }
  .item {
    min-height: 50px;
    padding: 7px 10px;

    .content {
      display: flex;
      height: 30px;
      line-height: 30px;
      margin-bottom: 5px;

      .label {
        text-align: left;
        width: 100px;
        font-size: 14px;
      }

      .value {
        flex: 1;
      }
    }
  }

  /deep/ .el-input-number {
    .el-input__inner {
      text-align: left;
    }
  }
}
</style>
